<template>
    <div class="page_lendMoney">
        <van-nav-bar title="申请借支" left-arrow @click-left="$router.back()" />

        <div class="jobArr" v-if="lendMoneyList.length">
            <job-item-for-lend v-for="(item, index) in lendMoneyList" :key="item.id" :id="item.id" :serchType="1"
                :keyWord="'lendMoney'" :jobItem="item" :path="$route.path"></job-item-for-lend>

            <van-pagination v-model="pageIndex" :total-items="total" :items-per-page="pageSize"
                @change="getPaginationValue_lendmoney" force-ellipses>
                <template #prev-text>
                    <van-icon name="arrow-left" />
                </template>
                <template #next-text>
                    <van-icon name="arrow" />
                </template>
                <template #page="{ text }">{{ text }}</template>
            </van-pagination>
        </div>
        <van-divider style="margin-top: 80px" v-else>暂无记录</van-divider>
    </div>
</template>

<script>
import jobItemForLend from './jobItemForLend'
import comPagination from '../../components/comPagination'

export default {
  name: 'lendMoney',
  components: {
    comPagination,
    jobItemForLend
  },

  data() {
    return {
      lendMoneyList: [],
      total: 0,
      pageIndex: 1,
      pageSize: 10
    }
  },

  created() {
    this._getListData()
  },

  methods: {
    async _getListData() {
      const resp = await this.$api.job.getJobLendMoney({
        pageIndex: this.pageIndex,
        pageSize: this.pageSize
      })

      if (resp.code === 200) {
        this.lendMoneyList = resp.data.jobs
        this.total = resp.data.count || 0
      }
    },

    toJobDetailPage(id) {
      console.log('已工作---子到父---进入详情', id)
      this.$router.push({
        path: `/jobDetail/${id}`
      })
    },

    getPaginationValue_lendmoney(val) {
      this.pageIndex = val
      // 指定页
      this._getListData()
    }
  }
}
</script>

<style lang="scss" scoped></style>
